/**
 * 
 */
package com.ideazd.api.controller;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ideazd.api.model.InterfaceLayout;
import com.jfinal.core.Controller;
import com.jfinal.ext.route.ControllerBind;
import com.jfinal.kit.PropKit;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Logger;

/**
 * @author yzz
 * @create 2016年3月21日 下午3:08:17
 */
@ControllerBind(controllerKey="layout")
public class InterfaceLayoutController extends Controller {
	private static final Logger log = Logger.getLogger(InterfaceLayoutController.class);
	
	/**
	 * 话题列表
	 */
	public void getLayout(){
		String interfaceName = getPara("interfaceName");
		Map<Object, Object> ret = new HashMap<Object,Object>();
		
		
		if(StrKit.isBlank(interfaceName)){
			ret.put("code","-2");
			ret.put("msg","必传参数不允许为空");
			renderJson(ret);
			return;
		}
		
		try {
			
			List <InterfaceLayout> layoutList = InterfaceLayout.dao.find("select * from sta_interface_layout where interfacename = '"+interfaceName+"'");
			List<Map<Object, Object>> dataList = new ArrayList<Map<Object, Object>>();
			
			for(InterfaceLayout layout : layoutList){
				Map<Object, Object> dataMap = new HashMap<Object,Object>();
				dataMap.put("interfaceUrl", layout.get("interfaceurl"));
				dataList.add(dataMap);
			}
			
			ret.put("code","0");
			ret.put("msg","成功");
			ret.put("data", dataList);
			
		} catch (Exception e) {
			ret.put("code","-1");
			ret.put("msg",e.getMessage());
		}
		
		renderJson(ret);
		return;
		
	}

}
